﻿<%
Class Cls_FormField

	Dim vID
	Dim vFID
	Dim vFieldTitle
	Dim vFieldName
	Dim vFieldType
	Dim vDefaultValue
	Dim vIsMustInput
	Dim LastError

	Private Sub Class_Initialize()
		Call ChkLogin("login")
		Call Initialize()
	End Sub

	Private Sub Class_Terminate()
		Call Initialize()
	End Sub

	Public Function Initialize()
		vID = 0
		vFID = 0
		vFieldTitle = ""
		vFieldName = ""
		vFieldType = ""
		vDefaultValue = ""
		vIsMustInput = 0
	End Function

	Public Function GetValue()
		vFID = Int(Request("FID"))
		vFieldTitle = Trim(Request.Form("oFieldTitle"))
		vFieldName = Trim(Request.Form("oFieldName"))
		vFieldType = Request.Form("oFieldType")
		vDefaultValue = Request.Form("oDefaultValue")
		vIsMustInput = Int(Request.Form("oIsMustInput"))
		GetValue = True
	End Function

	Public Function SetValue()
		Dim Rs
		Set Rs = DB("Select * From [{pre}FormField] Where [ID]=" & vID,1)
		If Rs.Eof Then Rs.Close : Set Rs = Nothing : LastError = "你所需要查询的记录 " & vID & " 不存在!" : SetValue = False : Exit Function
		vFieldTitle = Rs("FieldTitle")
		vFieldName = Rs("FieldName")
		vFieldType = Rs("FieldType")
		vDefaultValue = Rs("DefaultValue")
		vIsMustInput = Rs("IsMustInput")
		SetValue = True
	End Function

	Public Function Create()
	
  		dim t1:t1=timer()
	
		Dim Rs
		Set Rs = DB("Select * From [{pre}FormField]",3)
		Rs.addnew
		Rs("FormID") = vFID
		Rs("FieldTitle") = vFieldTitle
		Rs("FieldName") = vFieldName
		Rs("FieldType") = vFieldType
		Rs("DefaultValue") = vDefaultValue
		Rs("IsMustInput") = vIsMustInput
		Rs.Update : Rs.Close
		Set Rs = Nothing

		Create = True
	End Function

	Public Function Modify()
		Dim Rs,DelOldData,DelID
		Set Rs = DB("Select * From [{pre}FormField] Where [ID]=" & vID,3)
		If Rs.Eof Then Rs.Close : Set Rs = Nothing : LastError = "你所需要更新的记录 " & vID & " 不存在!" : Modify = False : Exit Function
		Rs("FieldTitle") = vFieldTitle
		Rs("FieldName") = vFieldName
		Rs("FieldType") = vFieldType
		Rs("DefaultValue") = vDefaultValue
		Rs("IsMustInput") = vIsMustInput
		Rs.Update : Rs.Close
		Modify = True
	End Function

	Public Function Delete()
		Call SetValue()
		Call DB("Delete From [{pre}FormField] Where [ID]=" & vID ,0) '# 删除信息
		Delete = True
	End Function
	
End Class
%>